package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/17.
 */
@HttpInlet(Conn.INLET_API_CLAIMS_INDEX)
public class GetApiLiPeiSearch extends BaseAsyGet<GetApiLiPeiSearch.Info> {

    public String type;

    public GetApiLiPeiSearch(AsyCallBack<GetApiLiPeiSearch.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {
        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            JSONArray array = jsonObject.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {
                JSONObject o = array.optJSONObject(i);
                Data d = new Data();
                d.id = o.optString("id");
                d.title = o.optString("title");
                info.dataList.add(d);
            }
            return info;
        }
        return null;
    }

    public static class Info {

        public String code, message;
        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {
        //        "data": [
//        {
//            "id": "2",
//                "title": "人保车险"
//        },
//        {
//            "id": "1",
//                "title": "平安保险"
//        }
//        ]
        public String id, title;
    }
}
